﻿// ELF.cs
// This program contains 2 struct that represent 2 different ELF contructs.
// The first is an elf header and the second is an elf header entry


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;

namespace armsim
{
    /// <summary>
    /// Struct of an Elf Header to be presumably materialized from a byte array
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct ELF_Header
    {
        public byte EI_MAG0, EI_MAG1, EI_MAG2, EI_MAG3, EI_CLASS, EI_DATA, EI_VERSION;
        byte unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8, unused9;
        public ushort e_type;
        public ushort e_machine;
        public uint e_version;
        public uint e_entry;
        public uint e_phoff;
        public uint e_shoff;
        public uint e_flags;
        public ushort e_ehsize;
        public ushort e_phentsize;
        public ushort e_phnum;
        public ushort e_shentsize;
        public ushort e_shnum;
        public ushort e_shstrndx;
    }

    /// <summary>
    /// Struct of an Elf Header Entry to be presumably materialized from a byte array
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct ELF_Header_Entry
    {
        public uint p_type;		    /* Segment type */
        public uint p_offset;		/* Segment file offset */
        public uint p_vaddr;		/* Segment virtual address */
        public uint p_paddr;		/* Segment physical address */
        public uint p_filesz;		/* Segment size in file */
        public uint p_memsz;		/* Segment size in memory */
        public uint p_flags;		/* Segment flags */
        public uint p_align;	 

    }


}
